Repository navigation
Parse recordings once and reuse numeric parser state - #872
Closed
Andrey1994 wants to merge 4 commits into
Closed
Andrey1994 wants to merge 4 commits into
Andrey1994 wants to merge 4 commits into
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
| System.IO.File.WriteAllText(path, "1,2\n3,4"); | ||
| var loaded = DataFilter.read_file(path); | ||
| if (loaded.GetLength(0) != 2 || loaded.GetLength(1) != 2 || | ||
| loaded[0, 1] != 3 || loaded[1, 0] != 2) |
| System.IO.File.WriteAllText(path, "1,2\n3,4"); | ||
| var loaded = DataFilter.read_file(path); | ||
| if (loaded.GetLength(0) != 2 || loaded.GetLength(1) != 2 || | ||
| loaded[0, 1] != 3 || loaded[1, 0] != 2) |
| [DllImport ("DataHandler", SetLastError = true, CallingConvention = CallingConvention.Cdecl)] | ||
| public static extern int read_file (double[] data, int[] num_rows, int[] num_cols, string file_name, int max_elements); | ||
| [DllImport ("DataHandler", SetLastError = true, CallingConvention = CallingConvention.Cdecl)] | ||
| public static extern int prepare_file_read (string file_name, int[] handle, int[] rows, int[] cols); |
| [DllImport ("DataHandler", SetLastError = true, CallingConvention = CallingConvention.Cdecl)] | ||
| public static extern int prepare_file_read (string file_name, int[] handle, int[] rows, int[] cols); | ||
| [DllImport ("DataHandler", SetLastError = true, CallingConvention = CallingConvention.Cdecl)] | ||
| public static extern int copy_file_read (int handle, double[,] data, int capacity); |
| switch (PlatformHelper.get_library_environment ()) | ||
| { | ||
| case LibraryEnvironment.x64: | ||
| return DataHandlerLibrary64.prepare_file_read (file_name, handle, rows, cols); |
| case LibraryEnvironment.x64: | ||
| return DataHandlerLibrary64.prepare_file_read (file_name, handle, rows, cols); | ||
| case LibraryEnvironment.x86: | ||
| return DataHandlerLibrary32.prepare_file_read (file_name, handle, rows, cols); |
| switch (PlatformHelper.get_library_environment ()) | ||
| { | ||
| case LibraryEnvironment.x64: | ||
| return DataHandlerLibrary64.copy_file_read (handle, data, capacity); |
| case LibraryEnvironment.x64: | ||
| return DataHandlerLibrary64.copy_file_read (handle, data, capacity); | ||
| case LibraryEnvironment.x86: | ||
| return DataHandlerLibrary32.copy_file_read (handle, data, capacity); |
| switch (PlatformHelper.get_library_environment ()) | ||
| { | ||
| case LibraryEnvironment.x64: | ||
| return DataHandlerLibrary64.release_file_read (handle); |
| case LibraryEnvironment.x64: | ||
| return DataHandlerLibrary64.release_file_read (handle); | ||
| case LibraryEnvironment.x86: | ||
| return DataHandlerLibrary32.release_file_read (handle); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
File loading constructs a stream per numeric token and the bindings parse the recording twice. Reuse one classic-locale numeric stream and add immutable read snapshots so Python and C# parse once, then copy into caller-owned output. C# also avoids the intermediate flat-to-matrix copy. Existing C entry points remain available; counting validates input without retaining all parsed values.
Snapshots have explicit prepare/copy/release operations, capacity checks, and shared ownership for concurrent copy/release. Bindings release them in finally blocks. Strict finite-number, token, delimiter, shape, and output-capacity validation is preserved.
Validation: MSVC Release /MT native build; 20 Python signal-processing tests and C# regression executable passed against the newly built DLL. Added malformed-input, snapshot lifetime/file-change, capacity/no-write-on-error, released-handle coverage, and concurrent copies racing release with no partial output. Tests use the existing Windows/Unix CI suites. A local 4 MB recording took 0.47–0.49 s after warm-up, versus the previous 1.05–1.24 s baseline; this is an operation-specific local measurement.
Also repair the shared CI failures: stage native dylibs beside the macOS C# regression executable, report C++ test exceptions through a nonzero exit status, and guard allocation failure/overflow in the macOS Bluetooth pipe resize.
Part of #601. Based directly on master and independent of #871.